package com.TeamJigsaw.DanteTrail.Presenters;

import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;

import com.TeamJigsaw.DanteTrail.Models.Checkpoint;
import com.TeamJigsaw.DanteTrail.Models.Party;
import com.TeamJigsaw.DanteTrail.Views.MainViewFrame;
import com.TeamJigsaw.DanteTrail.Views.Interfaces.HuntingViewInterface;

public class HuntingViewController implements ViewController{
	
	private HuntingViewInterface hunt;
	private MainViewFrame mainView;
	private Party party;
	public HuntingViewController(Party party, List<Checkpoint> checkpoints, MainViewFrame mainView)
	{
		this.mainView = mainView;
		this.party = party;
		this.hunt = mainView.getHuntingView();
		this.hunt.createHuntingGame(party, party.getLevel(checkpoints));
		createListeners();
	}
	/**
	 * Creates the listeners needed for the components in the view
	 */
	@Override
	public void createListeners() {
		LeaveListener leave = new LeaveListener();
		hunt.setLeaveListener(leave);
	}
	
	private class LeaveListener implements ActionListener {
		@Override
		public void actionPerformed(ActionEvent e) {
			System.out.println("Leave Pressed");
			((CardLayout) mainView.getContentPane().getLayout()).show(mainView.getContentPane(), "Game");
			mainView.setTitle("Trail");
			GameViewController gvc = new GameViewController(party, mainView);
			hunt.getHuntDisplay().endGame();
		}
	}

}
